home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 003 / _gs / !GS / h / GDEVPRN < prev    next >
Text File  |  1991-10-25  |  5KB  |  149 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gdevprn.h */
  21. /* Common header file for memory-buffered black-and-white printers */
  22.  
  23. #include "memory_.h"
  24. #include "string_.h"
  25. #include "gs.h"
  26. #include "gxbitmap.h"
  27. #include "gsmatrix.h"            /* for gxdevice.h */
  28. #include "gxdevice.h"
  29. #include "gxdevmem.h"
  30. #include "gxclist.h"
  31.  
  32. /* Define the parameters for the printer rendering method. */
  33. /* If the entire bitmap fits in PRN_MAX_BITMAP, render in RAM, */
  34. /* otherwise use a command list with a size of PRN_BUFFER_SPACE. */
  35. #ifdef __MSDOS__
  36. /* MS-DOS machines have little dinky RAMs.... */
  37. #  define PRN_MAX_BITMAP 20000
  38. #  define PRN_BUFFER_SPACE 20000
  39. #else
  40. /* Unix and VMS machines have great big hulking RAMs.... */
  41. #  define PRN_MAX_BITMAP 300000L
  42. #  define PRN_BUFFER_SPACE 250000L
  43. #endif
  44.  
  45. /****** ENABLE OR DISABLE DIRECT WRITING TO PRINTER ******/
  46. #ifdef __MSDOS__
  47. #  define WRITE_TO_PRN 1
  48. #else
  49. #  define WRITE_TO_PRN 0
  50. #endif
  51.  
  52. /* Define the declaration macro for print_page procedures. */
  53. #define dev_proc_print_page(proc)\
  54.   int proc(P2(gx_device_printer *, FILE *))
  55.  
  56. /* The device descriptor */
  57. typedef struct gx_device_printer_s gx_device_printer;
  58. struct gx_device_printer_s {
  59.     gx_device_common;
  60.     /* The following is required only for devices where */
  61.     /* output_page is gdev_prn_output_page; */
  62.     /* it is ignored for other devices. */
  63.     dev_proc_print_page((*print_page));
  64.     /* The following two items must be set before calling */
  65.     /* the device open routine. */
  66.     long buffer_space;    /* amount of space for clist buffer, */
  67.                     /* 0 means don't use clist */
  68.     int write_to_prn;    /* if true, write directly to printer */
  69.     byte *buf;            /* buffer for rendering */
  70.     char cfname[30];        /* clist file name */
  71.     FILE *cfile;            /* command list scratch file */
  72.     gx_device_clist clist;        /* buffer device */
  73.     gx_device *bdev;        /* clist or clist.mem */
  74.     char fname[30];            /* scratch file name, approx */
  75.                     /* strlen(SCRATCH_TEMPLATE)+1 */
  76.     FILE *file;            /* scratch file */
  77. };
  78.  
  79. /* Macro for casting gx_device argument */
  80. #define prn_dev ((gx_device_printer *)dev)
  81.  
  82. /* Standard device procedures for printers */
  83. dev_proc_open_device(gdev_prn_open);
  84. dev_proc_output_page(gdev_prn_output_page);
  85. dev_proc_close_device(gdev_prn_close);
  86. dev_proc_map_rgb_color(gdev_prn_map_rgb_color);
  87. dev_proc_map_color_rgb(gdev_prn_map_color_rgb);
  88. dev_proc_fill_rectangle(gdev_prn_fill_rectangle);
  89. dev_proc_tile_rectangle(gdev_prn_tile_rectangle);
  90. dev_proc_copy_mono(gdev_prn_copy_mono);
  91. dev_proc_copy_color(gdev_prn_copy_color);
  92.  
  93. /* Macro for generating procedure table */
  94. #define prn_procs(proc_open, proc_output_page, proc_close)\
  95.   prn_color_procs(proc_open, proc_output_page, proc_close,\
  96.           gdev_prn_map_rgb_color, gdev_prn_map_color_rgb)
  97. #define prn_color_procs(proc_open, proc_output_page, proc_close, proc_map_rgb_color, proc_map_color_rgb) {\
  98.     proc_open,\
  99.     gx_default_get_initial_matrix,\
  100.     gx_default_sync_output,\
  101.     proc_output_page,\
  102.     proc_close,\
  103.     proc_map_rgb_color,\
  104.     proc_map_color_rgb,\
  105.     gdev_prn_fill_rectangle,\
  106.     gdev_prn_tile_rectangle,\
  107.     gdev_prn_copy_mono,\
  108.     gdev_prn_copy_color,\
  109.     gx_default_draw_line,\
  110.     gx_default_fill_trapezoid,\
  111.     gx_default_tile_trapezoid\
  112. }
  113.  
  114. /* The standard printer device procedures */
  115. /* (using gdev_prn_open/output_page/close). */
  116. extern gx_device_procs prn_std_procs;
  117.  
  118. /* Macro for generating the device descriptor. */
  119. /*
  120.  * The computations of page width and height in pixels should really be
  121.  *    ((int)(page_width_inches*x_dpi))
  122.  * but some compilers (the Ultrix 3.X pcc compiler and the HPUX compiler)
  123.  * can't cast a computed float to an int.  That's why we specify
  124.  * the page width and height in inches/10 instead of inches.
  125.  */
  126. #define prn_device(procs, dev_name, width_10ths, height_10ths, x_dpi, y_dpi, l_margin, b_margin, r_margin, t_margin, color_bits, print_page) {\
  127.     sizeof(gx_device_printer),\
  128.     &procs,\
  129.     dev_name,\
  130.     (int)((long)width_10ths * x_dpi / 10),    /* width */\
  131.     (int)((long)height_10ths * y_dpi / 10),    /* height */\
  132.     x_dpi,\
  133.     y_dpi,\
  134.     l_margin, b_margin, r_margin, t_margin,\
  135.     color_bits > 1,    /* has_color */\
  136.     1,        /* rgb_max_value */\
  137.     ((color_bits > 1) & (color_bits < 8) ? 8 : color_bits),    /* bits per color pixel */\
  138.     0,        /* not initialized yet */\
  139.     print_page,\
  140.     0,\
  141.     WRITE_TO_PRN\
  142. }
  143.  
  144. /* Common procedures defined in gdevprn.c */
  145. int gdev_prn_open_printer(P1(gx_device *));
  146. int gdev_prn_copy_scan_lines(P4(gx_device_printer *, int, byte *, uint));
  147. void gdev_prn_transpose_8x8(P4(byte *, int, byte *, int));
  148. int gdev_prn_close_printer(P1(gx_device *));
  149.